import { createStore, createLogger } from 'vuex';

//组装对象
const files = require.context('.', true, /\.ts$/);
const modules = {};
files.keys().forEach((key: string) => {
  if (key === './index.ts') return;
  const childModule = files(key).default;
  const moduleKey = key.slice(key.lastIndexOf('/') + 1).replace('.ts', '');
  console.log('childModule', childModule);
  modules[moduleKey] = childModule;
});

console.log('modules', modules);
export default createStore({
  modules: {
    ...modules
  },
  plugins: [createLogger()],
  strict: process.env.NODE_ENV !== 'production'
})